<template>
  <div class="dashboard-container">
    <div class="dashboard-text">Welcome: {{ name }} !</div>
    <el-card>
      <PanelGroup :info="info"></PanelGroup>
    </el-card>
    <el-card class="map-chart">
      <MapChart :mapData="mapData"></MapChart>
    </el-card>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { DashboardIndex, DashboardIndexMap } from '@/api';
import PanelGroup from './DashboardComponents/PanelGroup.vue'
import MapChart from './DashboardComponents/MapChart.vue'

// import { info } from 'sass'; // 错误的引入方式

export default {
  name: 'Dashboard',
  components: { PanelGroup, MapChart },
  data() {
    return {
      info: {},
      mapData: {}
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  methods: {
    getDashboardData() {
      DashboardIndex().then(res => {
        console.log(res)
        if (res.code === 200) {
          this.info = res.data;
        }
      })
    },
    getMapData() {
      DashboardIndexMap().then(res => {
        console.log(res)
        if (res.code === 200) {
          this.mapData = res.data;
        }
      })
    }
  },
  mounted() {
    this.getDashboardData()
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }

  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}

.map-chart {
  margin-top: 20px;
  height: 500px;
}
</style>
